#pragma once

namespace xs
{

class RendererImpl;

struct Particle
{
	pos2	position;
	vec2	velocity;
	
	float	energy;
	float	life_time;

	float	rotation_speed;
	float	rotation;
};

class ParticleSystemImpl: public ParticleSystem
{
public:
									ParticleSystemImpl(const ParticleSystemDesc &desc, Renderer *xse);
									~ParticleSystemImpl();

	virtual bool					animate(const double &elapsed_ms);
	virtual void					draw();

	virtual ParticleSystemDesc&		get_desc();
private:
	std::vector<Particle>			particles;
	ParticleSystemDesc				desc;
	Renderer*						xse;
	Quad							quad;
	double							accumulated_time;
	u32								particles_created;

	void							emit(int new_particles);
	void							set_particle(Particle &p);
};

}